

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>新增服务点</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div style="height: 42px;line-height: 42px;padding: 0 15px;border-bottom: 1px solid #f6f6f6;color: #333;border-radius: 2px 2px 0 0;font-size: 14px;">
            <span><i id="return" class="layui-icon layui-icon-return" style="padding-right: 10px;"></i></span>
            <span>新增服务点</span>
        </div>

        <div class="layui-card-body" style="padding: 15px;">
            <form class="layui-form" action="" lay-filter="component-form-group" style="height: 100%">

                <div class="layui-form-item">
                    <label class="layui-form-label">名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" style="width: 300px" lay-verify="required" autocomplete="off" placeholder="请输入服务点名称" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">服务金额</label>
                    <div class="layui-input-block">
                        <input type="text" name="price" style="width: 300px" lay-verify="required" autocomplete="off" placeholder="请输入服务点的服务单价" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">余额折扣</label>
                    <div class="layui-input-block">
                        <div class="layui-inline">
                        <input type="text" name="discountRate"  lay-verify="checkDiscountRate" autocomplete="off" placeholder="请输入折扣" class="layui-input">
                        </div>
                        <div class="layui-inline">
                            折<span style="padding-left:20px;color: red">折扣最多支持一位小数，且大于1，小于9.9。</span>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: auto">洗车设备编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="deviceNo" style="width: 300px" lay-verify="required" autocomplete="off" placeholder="请输入设备编号" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: auto">入闸设备编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="enterRomId" style="width: 300px" lay-verify="required" autocomplete="off" placeholder="请输入入闸口romid" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: auto">出闸设备编号</label>
                    <div class="layui-inline">
                        <input type="text" name="exitRomId" style="width: 300px" lay-verify="required" autocomplete="off" placeholder="请输入出闸口romid" class="layui-input">
                    </div>
                    <div class="layui-inline">
                        <span style="color: red">如果出入闸是同一个则填相同的romid</span>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">营业时间</label>
                    <div class="layui-input-block">
                        <input type="text" name="openTimeDesc" style="width: 300px" lay-verify="required" autocomplete="off" placeholder="手动填写。如:24小时营业" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">营业状态</label>
                    <div class="layui-input-inline">
                        <select name="openStatus" lay-verify="required">
                            <option value="">请选择</option>
                            <option value="0">即将开业</option>
                            <option value="1">正常营业</option>
                            <option value="2">站点设备维护</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">营业说明</label>
                    <div class="layui-input-block">
                        <input type="text" name="remark" style="width: 300px"  autocomplete="off" placeholder="营业状态补充说明。如:将在5月7日恢复营业" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-inline" >
                        <label class="layui-form-label">服务点地址</label>
                        <div id="r-result" class="layui-input-inline" style="width: 300px;">
                            <input type="text" id="suggestId" placeholder="请输入服务点详细地址" size="20" value="" class="layui-input" />
                        </div>
                        <div class="layui-input-inline">
                            <div class="layui-btn layui-btn-sm" id="addPoint" onclick="addPoint()">确定</div>
                        </div>
                        <br/>
                    </div>
                    <div id="searchResultPanel" style="border:1px solid #C0C0C0;width:250px;height:auto; display:none;"></div>
                </div>
                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-inline" >
                        <div class="layui-input-inline" style="padding-left:20px;display: none;" id="showResult">
                            <div style="width: 200px;">地址：<span id="xAddress" value=""></span></div>
                            <div>经度：<span id="xPoint" value=""></span></div>
                            <div>纬度：<span id="yPoint" value=""></span></div>
                        </div>
                    </div>
                </div>

                <div style="margin-top: -600px; margin-left: 700px;position:absolute;left:10px;top:610px;width:50%;height:450px;border: 1px red solid; float: right;">
                <div id="l-map" style="height:450px;width:100%;"></div>
                </div>

                <div class="layui-form-item layui-layout-admin">
                    <div class="layui-input-block">
                        <div class="layui-footer" style="left: 0;">
                            <button class="layui-btn" lay-submit="" lay-filter="component-form-demo1">提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                            <button type="button" class="layui-btn" onclick="bMapTransqqMap()">重置</button>
                        </div>
                    </div>
                </div>
                <input type="hidden" id="address" name="address" value="">
                <input type="hidden" id="lng" name="lng" value="">
                <input type="hidden" id="lat" name="lat" value="">
            </form>
        </div>
    </div>
</div>
<script src="/public/layuiadmin/layui/layui.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="https://api.map.baidu.com/api?ak=gLfdG5Wkt28RFi9IRzGw5M7I8aL155Fq&v=2.0&services=true"></script>
<script src="/public/js/baidu.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'laydate','layer','element'], function(){
        var $ = layui.$
                ,admin = layui.admin
                ,element = layui.element
                ,layer = layui.layer
                ,laydate = layui.laydate
                ,form = layui.form;

        $(document).on('click','#return',function(){
                window.location.href = "/station/list";
        });

        /* 自定义验证规则 */
        form.verify({
            checkDiscountRate:function (value) {
                if(!/^[1-9]+([.]\d{0,1})?$/.test(value)){
                    return '折扣最多包含一位小数';
                }
            }
        });

        /* 监听提交 */
        form.on('submit(component-form-demo1)', function(data){
            var data=data.field;
            data.pointList =JSON.stringify(str);

            if(data.lng == "" || data.lat == ""){
                layer.msg('请输入地址，从提示的地址中选择服务点');
                return false;
            }

            if(data.openStatus == ""){
                layer.msg('请营业状态');
                return false;
            }
            $.post("/station/saveStation", data, function (result) {
                if (result.code > 0) {
                    layer.msg(result.msg);
                } else {
                    window.location.href = "/station/list";
                }
            });
            return false;

        });
    });

    function bMapTransqqMap() {
        var lng=document.getElementById("xPoint").innerHTML;
        var lat=document.getElementById("yPoint").innerHTML;
        var x_pi = (3.14159265358979324 * 3000.0) / 180.0;
        var x = lng - 0.0065;
        var y = lat - 0.006;
        var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
        var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
        var lngs = z * Math.cos(theta);
        var lats = z * Math.sin(theta);
        console.log(lngs+","+lats);
        //alert(lngs+","+lats);
    }
</script>

</body>
</html>
